const Home = () => import("@/pages/Home")
const Login = () => import("@/pages/Login")
const Register = () => import("@/pages/Register")
const Search = () => import("@/pages/Search")
const Detail = () => import("@/pages/Detail");
const AddCartSuccess = () => import("@/pages/AddCartSuccess");
const ShopCart = () => import("@/pages/ShopCart");
const Trade = () => import("@/pages/Trade");
const Pay = () => import("@/pages/Pay");
const PaySuccess = () => import("@/pages/PaySuccess");
const Center = () => import("@/pages/Center");
const MyOrder = () => import("@/pages/Center/components/MyOrder");
const TeamOrder = () => import("@/pages/Center/components/TeamOrder");

export default [
    {
        name: "home",
        path: "/home",
        component: Home,
    },
    {
        path: "/search/:searchKey?",
        name: "search",
        component: Search
    },
    {
        name: "login",
        path: "/login",
        component: Login,
        meta: {
            isFooterHide: true
        }
    },
    {
        name: "register",
        path: "/register",
        component: Register,
        meta: {
            isFooterHide: true
        }
    },
    {
        path: "/detail/:skuId",
        component: Detail,
        name: "detail",
    },
    {
        path: "/addCartSuccess",
        component: AddCartSuccess,
        name: "addCartSuccess",
    },
    {
        path: "/shopCart",
        component: ShopCart,
        name: "shopCart",
    },
    {
        path: "/trade",
        component: Trade,
        name: "trade",
        beforeEnter: (to, from, next) => {
            if(from.name!="shopCart") return next("/shopCart")
            next()
        }
    },
    {
        path: "/pay",
        component: Pay,
        name: "pay",
        beforeEnter: (to, from, next) => {
            if(from.name!="trade") return next("/trade")
            next()
        }
    },
    {
        path: "/center",
        component: Center,
        redirect: "/center/myOrder",
        children:[
            {
                path:"myOrder",
                component:MyOrder,
                name:"myOrder"
            },
            {
                path:"teamOrder",
                component:TeamOrder,
                name:"teamOrder"
            },
        ]
    },
    {
        path: "/paySuccess",
        component: PaySuccess,
        name: "paySuccess",
        beforeEnter: (to, from, next) => {
            if(from.name!="pay") return next("/pay")
            next()
        }
    },
    {
        path: "/",
        redirect: "/home"
    },
    // {
    //     path:"/*",
    //     component:Notfound
    // }
]